<!DOCTYPE html>
<html>
    <head>
        <title>DOM XPath Example</title>      
    </head>
    <body>
        <p>This example gets all nodes matching the expression <code>employee/name</code>.</p>
        <script type="text/javascript">
            var xmldom = (new DOMParser()).parseFromString("<employees><employee title=\"Software Engineer\"><name>Nicholas C. Zakas</name></employee><employee title=\"Salesperson\"><name>Jim Smith</name></employee></employees>", "text/xml");
            var serializer = new XMLSerializer();
            var result = xmldom.evaluate("employee/name", xmldom.documentElement, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);

            var message = "There are " + result.snapshotLength + " matching nodes.\n";
            var count = 0;
                       
            if (result != null){
                for (var i=0; i < result.snapshotLength; i++) {                       
                    message += serializer.serializeToString(result.snapshotItem(i)) + "\n";
                }
            }
                       
            alert(message);
            
        </script>
 
 
    </body>
</html>
